package com.ai.imagetext.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "generated_images")
@EqualsAndHashCode(callSuper = false)
public class GeneratedImage {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "original_image_id", nullable = false)
    @ToString.Exclude
    @JsonIgnore
    private Image originalImage;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "generated_image_id", nullable = false)
    @ToString.Exclude
    @JsonIgnore
    private Image generatedImage;
    
    @Column(name = "generation_prompt", columnDefinition = "TEXT")
    private String generationPrompt;
    
    @Column(name = "generation_params", columnDefinition = "TEXT")
    private String generationParams;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "ai_generation_status")
    private AIGenerationStatus aiGenerationStatus = AIGenerationStatus.PENDING;
    
    @Column(name = "similarity_score", precision = 3, scale = 2)
    private BigDecimal similarityScore;
    
    @CreationTimestamp
    @Column(name = "created_at")
    private LocalDateTime createdAt;
    
    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
    
    @Column(name = "is_deleted")
    private Boolean isDeleted = false;

    @JoinColumn(name = "user_id", nullable = false)
    private Long userId;
    
    public enum AIGenerationStatus {
        PENDING, SUCCESS, FAILED
    }
}